package me.zhengjie.modules.management.rest.admin;

import com.sun.net.httpserver.Authenticator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.management.domain.ConferenceRecord;
import me.zhengjie.modules.management.domain.Pageable;
import me.zhengjie.modules.management.service.ConferenceRecordService;
import me.zhengjie.modules.management.service.MrAppointmentRepService;
import me.zhengjie.modules.management.service.dto.ConferenceRecordQueryCriteria;
import me.zhengjie.modules.management.service.dto.MrRecordRepDto;
import me.zhengjie.utils.ExcelUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @Author: chenxin.jiang
 * @Date: 2020/12/17
 * @Description:
 */
@RestController
@RequiredArgsConstructor
@Api(tags ="MR:培训室预约报表")
@RequestMapping("/api/appointmentRep")
public class MrAppointmentRepController {

    private final MrAppointmentRepService mrAppointmentRepService;

    @GetMapping()
    @Log("获取报表数据")
    @ApiOperation("获取报表数据")
    public Object queryByCriteria(ConferenceRecordQueryCriteria conferenceRecordQueryCriteria,Pageable pageable){
        return mrAppointmentRepService.Query(conferenceRecordQueryCriteria,pageable);
    }

    @GetMapping("/export")
    @Log("导出报表数据")
    @ApiOperation("导出报表数据")
    public Object export(ConferenceRecordQueryCriteria conferenceRecordQueryCriteria){
        List<MrRecordRepDto> export = mrAppointmentRepService.Export(conferenceRecordQueryCriteria);
        //ExcelUtil.download(response,MrRecordRepDto.class,export);
        return export;
    }
}
